package cn.itsource.ldj.org.service.impl;

import cn.itsource.ldj.org.domain.Detail;
import cn.itsource.ldj.org.domain.Dictionaries;
import cn.itsource.ldj.org.mapper.DictionariesMapper;
import cn.itsource.ldj.org.query.DictionariesQuery;
import cn.itsource.ldj.org.service.IDictionariesService;
import cn.itsource.ldj.util.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictionariesServiceImpl implements IDictionariesService {

    @Autowired
    private DictionariesMapper dictionariesMapper;

    @Override
    public List<Dictionaries> findAll() {
        return dictionariesMapper.findAll();
    }

    @Override
    public Dictionaries findOne(Long id) {
        return dictionariesMapper.findOne(id);
    }

    @Override
    public void update(Dictionaries dictionaries) {
        dictionariesMapper.update(dictionaries);
    }

    @Override
    public void save(Dictionaries dictionaries) {
        dictionariesMapper.save(dictionaries);
    }

    @Override
    public void delete(Long id) {
        dictionariesMapper.delete(id);
    }

    @Override
    public QueryResult<Dictionaries> queryPage(DictionariesQuery query) {

        Integer total = dictionariesMapper.findCount(query);

        List<Dictionaries> data = dictionariesMapper.queryPage(query);
        return new QueryResult<>(total, data);
    }

    @Override
    public void batchRemove(List<Long> ids) {
        dictionariesMapper.batchRemove(ids);
    }


    @Override
    public QueryResult<Detail> findAllDetail(DictionariesQuery query) {

        Integer total = dictionariesMapper.findCountDetail(query);

        List<Detail> data =  dictionariesMapper.findAllDetail(query);
        return new QueryResult<>(total, data);
    }

    @Override
    public void detailUpdate(Detail detail) {
        dictionariesMapper.detailUpdate(detail);
    }

    @Override
    public void detailSave(Detail detail) {
        dictionariesMapper.detailSave(detail);
    }

    @Override
    public void detailDelete(Long id) {
        dictionariesMapper.detailDelete(id);
    }
}
